#include "iostream"
#include <sys/socket.h>
#include <stdlib.h>
#include <unistd.h>
using namespace std; 

int main(){
	int fd[2]; 
	int pid; 
	if(socketpair(AF_UNIX,SOCK_STREAM,0,fd)==-1){
		cout << "error" << endl;
		exit(-1);
	}
	pid = fork(); 
	if(pid < 0){
		cout << "fork error \n"; 
		exit(-1);
	}
	else if(pid > 0){
		write(fd[0],"hello",5);
		sleep(3);
		cout << "quit\n";
	}
	else{
		char buf[10]={0};
		read(fd[1],buf,9);
		cout << buf << endl;
	}

}
